package no.gnet.edvd.statemachine;

public enum BetState implements State {

	INITIAL {
		public State nextState() {
			return OPEN_FOR_BETTING;
		}

		public boolean readyToTransition(Context context) {
			return true;
		}
	},
	OPEN_FOR_BETTING {
		public State nextState() {
			return BETTING_CLOSED;
		}

		public boolean readyToTransition(Context context) {
			return context.getEvent().getState().equals(OPEN_FOR_BETTING);
		}
	},

	BETTING_CLOSED {
		public State nextState() {
			return EVENT_DECIDED;
		}

		public boolean readyToTransition(Context context) {
			return context.getEvent().getState().equals(BETTING_CLOSED);
		}
	},

	EVENT_DECIDED {
		public State nextState() {
			return SETTLED;
		}

		public boolean readyToTransition(Context context) {
			return (context.getEvent().getState().equals(EVENT_DECIDED) && context.getEvent().getWinningOption() != null);
		}
	},

	SETTLED {
		public State nextState() {
			return HISTORICAL;
		}

		public boolean readyToTransition(Context context) {
			return true;
		}

	},

	HISTORICAL {
		public State nextState() {
			return null;
		}

		public boolean readyToTransition(Context context) {
			return true;
		}
	},

	DELETED {
		public State nextState() {
			return null;
		}

		public boolean readyToTransition(Context context) {
			return true;
		}

	};

}
